import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 半人马 - 火箭
 **/
export default class MSK_FireArrow extends AbilityBase {
    static instance: MSK_FireArrow;
    efBuffId = FourCC('Bzr0');
    constructor(id: string = 'Mmt1') {
        super(id);
        MSK_FireArrow.instance = this;
        this.init();
        // se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
        EventManager.onTakeAttack(this.onMissileHit.bind(this));
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {}
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    onMissileHit(d: DamageEventData) {
        if (GetUnitAbilityLevel(d.source, this.id) == 0) return;
        if (!UnitHasBuffBJ(d.target, this.efBuffId)) return;
        if (IsUnitAliveBJ(d.source) && IsUnitAliveBJ(d.target)) {
            DamageSystemInstance.applyFireDamage(d.target, d.source, UnitCommon.取攻击(d.source), this.id);
            UnitRemoveBuffBJ(this.efBuffId, d.target);
        }
    }
}
